Menu

Wiki usage

Creative Commons License
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 License.
Edit Sidebar
Main > SkyboxCreation

Main.SkyboxCreation History

Show minor edits - Show changes to output

February 03, 2005, at 12:12 AM by bjarne
Added lines 1-165:
!Skybox creation with Terragen

In this tutorial I will help you to create photo-realistic skyboxes for MOH:AA ( or most any game actually ).

(:toc:)

!!Get Terragen

Terragen is a fantastic program that lets you create outdoor environments and put a camera in thit to render exelent photographic quality pictures. It is not a free program, but the trial version allows you to render images up to 1200 * 960 resolution. So if you want more detail than that, you have to buy the program ( considering the possibilities of this program: its well spent money ). But this resolution is good enough for most maps ( the biggest standard sskyboxes shipped with MOH:AA are just 512 * 512 ).

Enough talk: get the Terragen application from http://www.planetside.co.uk/terragen/

!!Play with Terragen

I'm not going to teach you how to create landscapes in Terragen, there are some good documentation on this on the Terragen homepage. So play with the program a bit and see what it can do.

Img:terragen_render_ferry.jpg

Here is one angle from one of the test renders I did while writing this tutorial ( the original is 960 * 960 ).

!!Terragen tips

The first thing I rendered looked totally worthless. It was blocky and the promised photo-realism was nowhere to be found, then I found a little slider called "Detail" in the "Render Control" dialog window. Once you boost that to max, you get some sweet stuff (:eek:). But in doing so you also increase the rendering times, so use a lower settting while experimenting.

!!Rendering a skybox

One of the reasons that we can use Terragen to create skyboxes is that it uses a camera that you can control in a very exact way. Making a skybox is a matter of:

* Making a nice landscape that fits nicely with your map.
* Setting up the camera in all 6 directions and taking a picture in each direction.

To set up tha camera, you:

# Place it where you want it ( so you get a nice view in all directions ).
# Set the camera heading, pitch and bank to 0 ( Camera will look "North" ).
# Render and save the picture.
# Set the camera heading to 90 ( Camera will look "East" ).
# Render and save the picture.
# Set the camera heading to 180 ( Camera will look "South" ).
# Render and save the picture.
# Set the camera heading to 270 ( Camera will look "West" ).
# Render and save the picture.
# Set the camera heading to 0 and pitch to 90 ( Camera will look Up ).
# Render and save the picture.
# Set the camera heading to 0 and pitch to -90 ( Camera will look Down ).
# Render and save the picture.
# Done! :D

You think that is a lot of work? Well, not really, but I'm a nice guy so I made a script that you can run by pressing the "Animation..." button in the "Render Control" dialog window. Then press the "Execute script" and select a *.tgs ( Terragen script ) file. You can copy this text into a blank *.txt file and rename it to the *.tgs extension:

----
[=; The folder specified in InitAnim must already exist.=]
[=initanim "C:\temp\sky_", 1=]
[=; (necessary before using FRend)=]
[=CamH 270=]
[=CamP 0=]
[=CamB 0=]
[=Zoom 1=]
[=frend=]
[=CamH 0=]
[=CamP 0=]
[=CamB 0=]
[=Zoom 1=]
[=frend=]
[=CamH 90
[=CamP 0=]
[=CamB 0=]
[=Zoom 1=]
[=frend=]
[=CamH 180=]
[=CamP 0=]
[=CamB 0=]
[=Zoom 1=]
[=frend=]
[=CamH 180=]
[=CamP 90=]
[=CamB 0=]
[=Zoom 1=]
[=frend=]
[=CamH 180=]
[=CamP -90=]
[=CamB 0=]
[=Zoom 1=]
[=frend=]
----

The files generated will be saved in c:\temp and they will be named sky_0001.bmp to sky_0006.bmp.

If you think the angles and sequences are a bit strange, its because if you sequence the camera with these angles: you will get the same angles as in MOH:AA ( so the view of "up" and "left" that you see in Terragen will match the view of "up" and "left" that you see in Radiant ). This makes it easier to line up the direction of the sunlight and features of the map in general in Radiant to match the skybox.

!Convert the files

As MOH:AA does not support the *.bmp format, you must convert the images to jpeg or targa format. As the skybox uses no alpha channel, I suggest using JPEG format ( its also smaller ). If you dont have a good program to convert the images: I suggest you get IrfanView [[http://www.irfanview.com/]]. Its free for personal use and a very competent viewer indeed.

!!Create a shader

A skybox shader is a bit different than regular shaders:

----
textures/sky/my_very_own_sky
{
qer_editorimage textures/sky/my_very_own_sky_editor_image.tga
qer_keyword utility
qer_keyword sky
surfaceparm nolightmap
surfaceparm noimpact
surfaceparm sky
skyParms env/my_very_own_sky - -
}
----

...this shader says a few things, so from top line:

# Specifies that you can find this texture in Radiant under the "sky" section under textures, and that it is named "my_very_own_sky".
# Start of the shader block.
# "qer_editorimage" defines the image you will see in the Radiant texture viewer when the sky is loaded.
# "qer_keyword utility" says that you can search for this texture by using the word "utility".
# "qer_keyword sky" says that you can search for this texture by using the word "sky".
# "surfaceparm nolightmap" says that the texture will not be affected by lights ( a tree nex to it will not cast a shadow on the skybox ).
# "surfaceparm noimpact" says that the texture will not be affected by gunfire ( shoting it will not leave a mark ).
# "surfaceparm sky" says that... well, that it is a sky... basically... not really a lot more to say I guess.
# "skyParms env/my_very_own_sky - -" This one is where the black magic comes into play. It says that it expects to find a bunch of square textures in the "env" folder. What it does not state is what exactly it expects these textures to be named. I'll go into this in the next section.
# End of the shader block.

Put the shader above in a text file and rename the file "my_very_own_sky.shader" and place it in the "<MOHAA>\main\scripts" folder.

!!Naming and placing the textures.

As I mentioned in the shader section, the files need to be named in a special way. The file names must start with the name stated in the shader, and then special keywords are added to the end of the name.

Rename the files like this (copy this into a *.bat file so you can just run the batch file instead of doung the boring renaming manually ):

----
rename sky_0001.jpg my_very_own_sky_ft.jpg
rename sky_0002.jpg my_very_own_sky_lf.jpg
rename sky_0003.jpg my_very_own_sky_bk.jpg
rename sky_0004.jpg my_very_own_sky_rt.jpg
rename sky_0005.jpg my_very_own_sky_up.jpg
rename sky_0006.jpg my_very_own_sky_dn.jpg
pause
----

If you really eyeball the renaming you will see that it looks wrong... according to that renaming, the left and right textures will end up in switched places... yes they will, but thats because how MOH:AA wants it.

Place all the files in the "<MOHAA>\main\env" folder and you are almost done.

Now make a 64 * 64 thumbnail of one of the images that is most representative of the sky, rename it to "my_very_own_sky_editor_image.jpg" and place it in the "<MOHAA>\main\textures\sky\" folder.

!!Use the sky

By now you should be able to use your texture on a skybox in Radiant. B-)

!!Problems

----
'''PROBLEM''': You get the following error when loading a map with your home made sky texture: '''[=LoadTGA=]: Only type 2 (RGB), 3 (gray), and 10 (RGB) TGA images supported'''.

'''SOLUTION''': (Courtesy Markus Kuhn): You are trying to use a .jpg in a shader script. All shader scripts call for .TGA textures, even though the actual texture may be a .jpg. If the shader script is correct and you're still getting the error, then it means that you have saved the textures as progressive .jpgs. You've seen these on some web sites, where the picture is downloaded in phases, showing increasingly detailed versions of the entire image. The Q3 rendering engine cannot render these textures. You must save the .jpgs as '''baseline optimized'''.
----

![=L8R=]

Well, thats all for now, hope you can use it.

- [[Profiles/Bjarne]]

Recent Changes Printable View Page History Edit Page [Attributes] [Printable View] [WikiHelp]
Page last modified on March 03, 2005, at 11:13 PM